var addDigits = function (num) {
  if ((num + "").length == 1) return num;
  let stack = (num + "").split("");
  let sum = 0;
  for (let i = 0; i < stack.length; i++) {
    sum += parseInt(stack[i]);
  }
  return addDigits(sum);
};

for (let i = 0; i < 100; i++) {
  console.log(addDigits(i));
}
